package dao.oc_voyage_ben;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import java.util.List;

import entitybean.oc_voyage.EnitityBeanOc_Voyage;
import entitybean.oc_voyage_ben.EnitityBeanOc_Voyage_Ben;
import entitybean.oc_voyage_ice.EnitityBeanOc_Voyage_Ice;

public class DaoImpl_Oc_Voyage_Ben  extends HibernateDaoSupport implements Dao_Oc_Voyage_Ben{
	public void Insert_Oc_Voyage_Ben(EnitityBeanOc_Voyage_Ben e)
	{
		this.getHibernateTemplate().save(e);
	}
	public void Update_Oc_Voyage_Ben(EnitityBeanOc_Voyage_Ben e)
	{
		this.getHibernateTemplate().update(e);
	}
	public void Delete_Oc_Voyage_Ben(EnitityBeanOc_Voyage_Ben e)
	{
		this.getHibernateTemplate().delete(e);
	}
	public void Delete_Oc_Voyage_Ben(String id)
	{
		List<EnitityBeanOc_Voyage_Ben> list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Ben where del='OFF' and id in("+id+")");	
		for(int i=0;i<list.size();i++)
		{
			EnitityBeanOc_Voyage_Ben e=list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);
			
		}
	}
	@SuppressWarnings("unchecked")
	public List<EnitityBeanOc_Voyage_Ben> Find_Oc_Voyage_Ben_By_boatid(Integer id)
	{
		System.out.println("SQL="+"from EnitityBeanOc_Voyage_Ben where del='OFF' and boatid="+id);
		return this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Ben where del='OFF' and boatid="+id);
	
	}
	
	public EnitityBeanOc_Voyage_Ben Find_Oc_Voyage_Ben_By_id(String id)
	{
		List<EnitityBeanOc_Voyage_Ben>list=this.getHibernateTemplate().find("from EnitityBeanOc_Voyage_Ben where id="+id);
		EnitityBeanOc_Voyage_Ben e=new EnitityBeanOc_Voyage_Ben();
		if (list.size()>0)
		{
			e=list.get(0);	
		}
		return e;
		
		
	}
}
